





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>tvm.relay.backend &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
        <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
        <script src="../../../../_static/jquery.js"></script>
        <script src="../../../../_static/underscore.js"></script>
        <script src="../../../../_static/doctools.js"></script>
        <script src="../../../../_static/translations.js"></script>
    
    <script type="text/javascript" src="../../../../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../../../../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../../../../genindex.html" />
    <link rel="search" title="搜索" href="../../../../search.html" />
    <link rel="next" title="tvm.relay.dataflow_pattern" href="dataflow_pattern.html" />
    <link rel="prev" title="tvm.relay.analysis" href="analysis.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../../../../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../../../../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../../index.html">
          

          
            
            <img src="../../../../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../install/index.html">安装 TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../contribute/index.html">贡献者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../langref/index.html">语言参考</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">Python API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../runtime.html">tvm.runtime</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ndarray.html">tvm.runtime.ndarray</a></li>
<li class="toctree-l2"><a class="reference internal" href="../error.html">tvm.error</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html">tvm.ir</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html#module-tvm.instrument">tvm.instrument</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html#module-tvm.transform">tvm.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="../target.html">tvm.target</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html">tvm.tir</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#module-tvm.tir.transform">tvm.tir.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#tvm-tir-analysis">tvm.tir.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#module-tvm.tir.stmt_functor">tvm.tir.stmt_functor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../te.html">tvm.te</a></li>
<li class="toctree-l2"><a class="reference internal" href="../te.html#module-tvm.te.hybrid">tvm.te.hybrid</a></li>
<li class="toctree-l2"><a class="reference internal" href="../driver.html">tvm.driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html">tvm.relay</a></li>
<li class="toctree-l2"><a class="reference internal" href="frontend.html">tvm.relay.frontend</a></li>
<li class="toctree-l2"><a class="reference internal" href="nn.html">tvm.relay.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="vision.html">tvm.relay.vision</a></li>
<li class="toctree-l2"><a class="reference internal" href="image.html">tvm.relay.image</a></li>
<li class="toctree-l2"><a class="reference internal" href="transform.html">tvm.relay.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="analysis.html">tvm.relay.analysis</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">tvm.relay.backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataflow_pattern.html">tvm.relay.dataflow_pattern</a></li>
<li class="toctree-l2"><a class="reference internal" href="testing.html">tvm.relay.testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../autotvm.html">tvm.autotvm</a></li>
<li class="toctree-l2"><a class="reference internal" href="../auto_scheduler.html">tvm.auto_scheduler</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rpc.html">tvm.rpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="../micro.html">tvm.micro</a></li>
<li class="toctree-l2"><a class="reference internal" href="../contrib.html">tvm.contrib</a></li>
<li class="toctree-l2"><a class="reference internal" href="../graph_executor.html">tvm.contrib.graph_executor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../topi.html">tvm.topi</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vta/index.html">vta</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="../index.html">Python API</a> <span class="br-arrow">></span></li>
        
      <li>tvm.relay.backend</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../../../_sources/reference/api/python/relay/backend.rst.txt" rel="nofollow"> <img src="../../../../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-tvm.relay.backend">
<span id="tvm-relay-backend"></span><h1>tvm.relay.backend<a class="headerlink" href="#module-tvm.relay.backend" title="永久链接至标题">¶</a></h1>
<p>Backend codegen modules for relay.</p>
<span class="target" id="module-tvm.relay.backend.interpreter"></span><p>The Python interface to the Relay reference interpreter.</p>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.interpreter.ConstructorValue">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.interpreter.</span></span><span class="sig-name descname"><span class="pre">ConstructorValue</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fields</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">constructor</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.interpreter.ConstructorValue" title="永久链接至目标">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.interpreter.RefValue">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.interpreter.</span></span><span class="sig-name descname"><span class="pre">RefValue</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.interpreter.RefValue" title="永久链接至目标">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.interpreter.Executor">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.interpreter.</span></span><span class="sig-name descname"><span class="pre">Executor</span></span><a class="headerlink" href="#tvm.relay.backend.interpreter.Executor" title="永久链接至目标">¶</a></dt>
<dd><p>An abstract interface for executing Relay programs.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.interpreter.Executor.evaluate">
<span class="sig-name descname"><span class="pre">evaluate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">binds</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.interpreter.Executor.evaluate" title="永久链接至目标">¶</a></dt>
<dd><p>Evaluate a Relay expression on the executor.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<em>Optional</em><em>[</em><em>tvm.relay.Expr</em><em>]</em>) – The expression to evaluate.</p></li>
<li><p><strong>binds</strong> (<em>Optional</em><em>[</em><a class="reference internal" href="../ir.html#tvm.ir.Map" title="tvm.ir.Map"><em>Map</em></a><em>[</em><em>tvm.relay.Var</em><em>, </em><em>tvm.relay.Expr</em><em>]</em><em>]</em>) – Additional binding of free variable.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>val</strong> – The evaluation result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Union[function, <a class="reference internal" href="../runtime.html#tvm.runtime.Object" title="tvm.runtime.Object">Object</a>]</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.interpreter.Interpreter">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.interpreter.</span></span><span class="sig-name descname"><span class="pre">Interpreter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">device</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.interpreter.Interpreter" title="永久链接至目标">¶</a></dt>
<dd><p>Simple interpreter interface.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The module to support the execution.</p></li>
<li><p><strong>device</strong> (<a class="reference internal" href="../runtime.html#tvm.runtime.Device" title="tvm.runtime.Device"><em>Device</em></a>) – The runtime device to run the code on.</p></li>
<li><p><strong>target</strong> (<em>tvm.Target</em>) – The target option to build the function.</p></li>
<li><p><strong>CAUTION</strong> (<em>Despite the API the module is prepared upon each call to evaluate</em>) – </p></li>
<li><p><strong>create_executor.</strong> (<em>rather than once in</em>) – </p></li>
<li><p><strong>is</strong> (<em>That</em>) – </p></li>
<li><p><strong>code-block:</strong> (<em>.</em>) – python: executor = relay.create_executor(kind=”debug”, mod=module)
a = executor.evaluate(expr)(args1)
b = executor.evaluate(expr)(args2)</p></li>
<li><p><strong>efficiency</strong> (<em>will prepare all the bindings in module twice. For</em>) – </p></li>
<li><p><strong>hoist</strong> (<em>try to</em>) – </p></li>
<li><p><strong>possible</strong> (<em>calls to evaluate as high as</em>) – </p></li>
<li><p><strong>create_executor</strong> (<em>preferably immediately after</em>) – </p></li>
<li><p><strong>code-block:</strong> – python: func = relay.create_executor(kind=”debug”, mod=module).evaluate(expr)
a = func(args1)
b = func(args2)</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.backend.compile_engine"></span><p>Backend code generation engine.</p>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.LoweredOutput">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.compile_engine.</span></span><span class="sig-name descname"><span class="pre">LoweredOutput</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">outputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">implement</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.LoweredOutput" title="永久链接至目标">¶</a></dt>
<dd><p>Lowered output</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.CCacheKey">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.compile_engine.</span></span><span class="sig-name descname"><span class="pre">CCacheKey</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">source_func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.CCacheKey" title="永久链接至目标">¶</a></dt>
<dd><p>Key in the CompileEngine.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>source_func</strong> (<em>tvm.relay.Function</em>) – The source function.</p></li>
<li><p><strong>target</strong> (<em>tvm.Target</em>) – The target we want to run the function on.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.CCacheValue">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.compile_engine.</span></span><span class="sig-name descname"><span class="pre">CCacheValue</span></span><a class="headerlink" href="#tvm.relay.backend.compile_engine.CCacheValue" title="永久链接至目标">¶</a></dt>
<dd><p>Value in the CompileEngine, including usage statistics.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.get_shape">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.compile_engine.</span></span><span class="sig-name descname"><span class="pre">get_shape</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.get_shape" title="永久链接至目标">¶</a></dt>
<dd><p>Convert the shape to correct dtype and vars.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.get_valid_implementations">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.compile_engine.</span></span><span class="sig-name descname"><span class="pre">get_valid_implementations</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">op</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">out_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.get_valid_implementations" title="永久链接至目标">¶</a></dt>
<dd><p>Get all valid implementations from the op strategy.</p>
<p>Note that this function doesn’t support op with symbolic input shapes.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>op</strong> (<a class="reference internal" href="../ir.html#tvm.ir.Op" title="tvm.ir.Op"><em>tvm.ir.Op</em></a>) – Relay operator.</p></li>
<li><p><strong>attrs</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(在 Python v3.10)"><em>object</em></a>) – The op attribute.</p></li>
<li><p><strong>inputs</strong> (<a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="../te.html#tvm.te.Tensor" title="tvm.te.Tensor"><em>tvm.te.Tensor</em></a><em>]</em>) – Input tensors to the op.</p></li>
<li><p><strong>out_type</strong> (<em>relay.Type</em>) – The output type.</p></li>
<li><p><strong>target</strong> (<a class="reference internal" href="../target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a>) – The target to compile the op.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – The list of all valid op implementations.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[relay.op.OpImplementation]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.select_implementation">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.compile_engine.</span></span><span class="sig-name descname"><span class="pre">select_implementation</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">op</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">out_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_autotvm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.select_implementation" title="永久链接至目标">¶</a></dt>
<dd><p>Select the best implementation from the op strategy.</p>
<p>If use_autotvm is True, it’ll first try to find the best implementation
based on AutoTVM profile results. If no AutoTVM profile result is found,
it’ll choose the implementation with highest plevel.</p>
<p>If use_autotvm is False, it’ll directly choose the implementation with
highest plevel.</p>
<p>Note that this function doesn’t support op with symbolic input shapes.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>op</strong> (<a class="reference internal" href="../ir.html#tvm.ir.Op" title="tvm.ir.Op"><em>tvm.ir.Op</em></a>) – Relay operator.</p></li>
<li><p><strong>attrs</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(在 Python v3.10)"><em>object</em></a>) – The op attribute.</p></li>
<li><p><strong>inputs</strong> (<a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference internal" href="../te.html#tvm.te.Tensor" title="tvm.te.Tensor"><em>tvm.te.Tensor</em></a><em>]</em>) – Input tensors to the op.</p></li>
<li><p><strong>out_type</strong> (<em>relay.Type</em>) – The output type.</p></li>
<li><p><strong>target</strong> (<a class="reference internal" href="../target.html#tvm.target.Target" title="tvm.target.Target"><em>tvm.target.Target</em></a>) – The target to compile the op.</p></li>
<li><p><strong>use_autotvm</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether query AutoTVM to pick the best.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – The best op implementation and the corresponding output tensors.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)">tuple</a>(relay.op.OpImplementation, <a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[<a class="reference internal" href="../te.html#tvm.te.Tensor" title="tvm.te.Tensor">tvm.te.Tensor</a>])</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.CompileEngine">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.compile_engine.</span></span><span class="sig-name descname"><span class="pre">CompileEngine</span></span><a class="headerlink" href="#tvm.relay.backend.compile_engine.CompileEngine" title="永久链接至目标">¶</a></dt>
<dd><p>CompileEngine to get lowered code.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.CompileEngine.lower">
<span class="sig-name descname"><span class="pre">lower</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">source_func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mod_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'default'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.CompileEngine.lower" title="永久链接至目标">¶</a></dt>
<dd><p>Lower a source_func to a CachedFunc.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>source_func</strong> (<em>Union</em><em>[</em><em>tvm.relay.Function</em><em>, </em><a class="reference internal" href="#tvm.relay.backend.compile_engine.CCacheKey" title="tvm.relay.backend.compile_engine.CCacheKey"><em>CCacheKey</em></a><em>]</em>) – The source relay function.</p></li>
<li><p><strong>target</strong> (<em>tvm.Target</em>) – The target platform.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>cached_func</strong> – The result of lowering.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>CachedFunc</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.CompileEngine.jit">
<span class="sig-name descname"><span class="pre">jit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">source_func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.CompileEngine.jit" title="永久链接至目标">¶</a></dt>
<dd><p>JIT a source_func to a tvm.runtime.PackedFunc.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>source_func</strong> (<em>Union</em><em>[</em><em>tvm.relay.Function</em><em>, </em><a class="reference internal" href="#tvm.relay.backend.compile_engine.CCacheKey" title="tvm.relay.backend.compile_engine.CCacheKey"><em>CCacheKey</em></a><em>]</em>) – The source relay function.</p></li>
<li><p><strong>target</strong> (<em>tvm.Target</em>) – The target platform.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>jited_func</strong> – The result of jited function.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="../runtime.html#tvm.runtime.PackedFunc" title="tvm.runtime.PackedFunc">tvm.runtime.PackedFunc</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.CompileEngine.clear">
<span class="sig-name descname"><span class="pre">clear</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.CompileEngine.clear" title="永久链接至目标">¶</a></dt>
<dd><p>clear the existing cached functions</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.CompileEngine.items">
<span class="sig-name descname"><span class="pre">items</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.CompileEngine.items" title="永久链接至目标">¶</a></dt>
<dd><p>List items in the cache.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>item_list</strong> – The list of items.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[Tuple[<a class="reference internal" href="#tvm.relay.backend.compile_engine.CCacheKey" title="tvm.relay.backend.compile_engine.CCacheKey">CCacheKey</a>, <a class="reference internal" href="#tvm.relay.backend.compile_engine.CCacheValue" title="tvm.relay.backend.compile_engine.CCacheValue">CCacheValue</a>]]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.CompileEngine.shape_func_items">
<span class="sig-name descname"><span class="pre">shape_func_items</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.CompileEngine.shape_func_items" title="永久链接至目标">¶</a></dt>
<dd><p>List items in the shape_func_cache.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>item_list</strong> – The list of shape_func_items.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[Tuple[<a class="reference internal" href="#tvm.relay.backend.compile_engine.CCacheKey" title="tvm.relay.backend.compile_engine.CCacheKey">CCacheKey</a>, <a class="reference internal" href="#tvm.relay.backend.compile_engine.CCacheValue" title="tvm.relay.backend.compile_engine.CCacheValue">CCacheValue</a>]]</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.CompileEngine.dump">
<span class="sig-name descname"><span class="pre">dump</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.CompileEngine.dump" title="永久链接至目标">¶</a></dt>
<dd><p>Return a string representation of engine dump.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>dump</strong> – The dumped string representation</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.backend.compile_engine.get">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.compile_engine.</span></span><span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.compile_engine.get" title="永久链接至目标">¶</a></dt>
<dd><p>Get the global compile engine.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>engine</strong> – The compile engine.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>tvm.relay.backend.CompileEngine</p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-tvm.relay.backend.graph_executor_codegen"></span><p>A compiler from a Relay expression to TVM’s graph executor.</p>
<p>The compiler is built from a few pieces.</p>
<p>First we define a compiler from a single Relay expression to the
graph language. We require the expression to be a function.
The function’s parameters correspond to the placeholder/inputs
and model parameters found in the computation graph representation.
The body of the function represents the computation graph.</p>
<p>The compiler’s output is a program in the graph language, which is composed of
Node, NodeRef, InputNode, OpNode. This “little language” represents programs in
TVM’s graph format.</p>
<p>To connect to the graph executor, we use a printer that converts our graph format
into TVM’s JSON format. The resulting string can be loaded by
contrib.graph_executor or any other TVM runtime compatible systems.</p>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.graph_executor_codegen.GraphExecutorCodegen">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.graph_executor_codegen.</span></span><span class="sig-name descname"><span class="pre">GraphExecutorCodegen</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.graph_executor_codegen.GraphExecutorCodegen" title="永久链接至目标">¶</a></dt>
<dd><p>The compiler from Relay to the TVM runtime system.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.graph_executor_codegen.GraphExecutorCodegen.codegen">
<span class="sig-name descname"><span class="pre">codegen</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.graph_executor_codegen.GraphExecutorCodegen.codegen" title="永久链接至目标">¶</a></dt>
<dd><p>Compile a single function into a graph.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>func</strong> (<em>tvm.relay.Expr</em>) – The function to compile.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>graph_json</strong> (<em>str</em>) – The graph json that can be consumed by runtime.</p></li>
<li><p><strong>mod</strong> (<em>IRModule or Dict[str, IRModule]</em>) – The lowered functions.</p></li>
<li><p><strong>params</strong> (<em>Dict[str, tvm.nd.NDArray]</em>) – Additional constant parameters.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<span class="target" id="module-tvm.relay.backend.vm"></span><p>The Relay Virtual Machine.</p>
<p>Implements a Python interface to compiling and executing on the Relay VM.</p>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.backend.vm.compile">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.vm.</span></span><span class="sig-name descname"><span class="pre">compile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.vm.compile" title="永久链接至目标">¶</a></dt>
<dd><p>Compile the module to VM executable. A helper function for VMCompiler.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The Relay module to build.</p></li>
<li><p><strong>target</strong> (str, <a class="reference internal" href="../target.html#tvm.target.Target" title="tvm.target.Target"><code class="xref any py py-class docutils literal notranslate"><span class="pre">tvm.target.Target</span></code></a>, or dict of str(i.e.) – device/context name) to str/tvm.target.Target, optional
For heterogeneous compilation, it is a dictionary indicating context
to target mapping. For homogeneous compilation, it is a build target.</p></li>
<li><p><strong>target_host</strong> (str or <a class="reference internal" href="../target.html#tvm.target.Target" title="tvm.target.Target"><code class="xref any py py-class docutils literal notranslate"><span class="pre">tvm.target.Target</span></code></a>, optional) – Host compilation target, if target is device.
When TVM compiles device specific program such as CUDA,
we also need host(CPU) side code to interact with the driver
to setup the dimensions and parameters correctly.
target_host is used to specify the host side codegen target.
By default, llvm is used if it is enabled,
otherwise a stackvm intepreter is used.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – Input parameters to the graph that do not change
during inference time. Used for constant folding.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>exec</strong> – The VM executable that contains both library code and bytecode.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>tvm.runtime.vm.Executable</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.vm.VMCompiler">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.vm.</span></span><span class="sig-name descname"><span class="pre">VMCompiler</span></span><a class="headerlink" href="#tvm.relay.backend.vm.VMCompiler" title="永久链接至目标">¶</a></dt>
<dd><p>Compiler that compiles Relay module to VM executable.</p>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.vm.VMCompiler.set_params">
<span class="sig-name descname"><span class="pre">set_params</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">params</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.vm.VMCompiler.set_params" title="永久链接至目标">¶</a></dt>
<dd><p>Set constant parameters for the model.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>params</strong> (<em>dict of str to NDArray</em>) – Input parameters to the graph that do not change
during inference time. Used for constant folding.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.vm.VMCompiler.get_params">
<span class="sig-name descname"><span class="pre">get_params</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.vm.VMCompiler.get_params" title="永久链接至目标">¶</a></dt>
<dd><p>Return the updated weights.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.vm.VMCompiler.lower">
<span class="sig-name descname"><span class="pre">lower</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.vm.VMCompiler.lower" title="永久链接至目标">¶</a></dt>
<dd><p>Lower the module to VM bytecode.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The Relay module to build.</p></li>
<li><p><strong>target</strong> (str, <a class="reference internal" href="../target.html#tvm.target.Target" title="tvm.target.Target"><code class="xref any py py-class docutils literal notranslate"><span class="pre">tvm.target.Target</span></code></a>, or dict of str(i.e.) – device/context name) to str/tvm.target.Target, optional
For heterogeneous compilation, it is a dictionary indicating context
to target mapping. For homogeneous compilation, it is a build target.</p></li>
<li><p><strong>target_host</strong> (str or <a class="reference internal" href="../target.html#tvm.target.Target" title="tvm.target.Target"><code class="xref any py py-class docutils literal notranslate"><span class="pre">tvm.target.Target</span></code></a>, optional) – Host compilation target, if target is device.
When TVM compiles device specific program such as CUDA,
we also need host(CPU) side code to interact with the driver
to setup the dimensions and parameters correctly.
target_host is used to specify the host side codegen target.
By default, llvm is used if it is enabled,
otherwise a stackvm intepreter is used.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.vm.VMCompiler.codegen">
<span class="sig-name descname"><span class="pre">codegen</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.vm.VMCompiler.codegen" title="永久链接至目标">¶</a></dt>
<dd><p>Generate the kernel library.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.vm.VMCompiler.optimize">
<span class="sig-name descname"><span class="pre">optimize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">params</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.vm.VMCompiler.optimize" title="永久链接至目标">¶</a></dt>
<dd><p>Helper method that optimizes a Relay module via VM.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – </p></li>
<li><p><strong>target</strong> (str, <a class="reference internal" href="../target.html#tvm.target.Target" title="tvm.target.Target"><code class="xref any py py-class docutils literal notranslate"><span class="pre">tvm.target.Target</span></code></a>, or dict of str (i.e.) – device/context name) to str/tvm.target.Target, optional</p></li>
<li><p><strong>target_host</strong> (str or <a class="reference internal" href="../target.html#tvm.target.Target" title="tvm.target.Target"><code class="xref any py py-class docutils literal notranslate"><span class="pre">tvm.target.Target</span></code></a>, optional) – The compilation target for host.
By default, llvm is used if it is enabled,
otherwise a stackvm intepreter is used.</p></li>
<li><p><strong>params</strong> (<em>dict of str to NDArray</em>) – Input parameters to the graph that do not change
during inference time. Used for constant folding.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The optimized relay module.</p></li>
<li><p><strong>params</strong> (<em>dict</em>) – The parameters of the final module.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.backend.vm.VMCompiler.get_exec">
<span class="sig-name descname"><span class="pre">get_exec</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.vm.VMCompiler.get_exec" title="永久链接至目标">¶</a></dt>
<dd><p>Get the VM executable.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>exec</strong> – The VM executable that contains both library code and bytecode.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>tvm.runtime.vm.Executable</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.backend.vm.VMExecutor">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.backend.vm.</span></span><span class="sig-name descname"><span class="pre">VMExecutor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">device</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.backend.vm.VMExecutor" title="永久链接至目标">¶</a></dt>
<dd><p>An implementation of the executor interface for
the Relay VM.</p>
<p>Useful interface for experimentation and debugging
the VM can also be used directly from the API.
supported by <cite>tvm.runtime.vm</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mod</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">IRModule</span></code>) – The module to support the execution.</p></li>
<li><p><strong>device</strong> (<a class="reference internal" href="../runtime.html#tvm.runtime.Device" title="tvm.runtime.Device"><code class="xref py py-class docutils literal notranslate"><span class="pre">Device</span></code></a>) – The runtime device to run the code on.</p></li>
<li><p><strong>target</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">Target</span></code>) – The target option to build the function.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="dataflow_pattern.html" class="btn btn-neutral float-right" title="tvm.relay.dataflow_pattern" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="analysis.html" class="btn btn-neutral float-left" title="tvm.relay.analysis" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../../../../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>